// //加载更多
var more_content = document.getElementById('more_content');
var load_content = document.getElementById('load_content');
var nodes = more_content.childNodes;
var more_content_link;
for (i = 0; i < nodes.length; i++) {
    var node = nodes[i];

    if (String(node.innerText).indexOf('后一页') != -1) {
        more_content.removeChild(node);
        more_content_link = node.lastChild.firstChild.href;
        load_content.style = '';
    }else if(String(node.innerText).indexOf('前一页') != -1){
        more_content.removeChild(node);
    }
}


load_content.onclick = function () {
    // console.log(more_content_link);
    var load_progress = mdui.snackbar({
            timeout: 0,
            message: '加载中...',
            position: 'bottom'
        });
    load_content.style = 'display:none;';
    var currentContent = document.getElementById('content-body');
    $.ajax({
        url: more_content_link,
        type: 'get',
        success: function (data) {
            var xml = new DOMParser().parseFromString(
                data, 'text/html');
            var body = xml.getElementById('left').childNodes;
            // var nodes = body.item(1).childNodes;
            for (var i = 0; i < body.length; i++) {
                var itme = body[i];
                if (itme.nodeName !== '#text') {
                    if (String(itme.innerText).indexOf('后一页') !== -1) {
                        more_content_link = itme.childNodes.item(1).lastChild.lastChild.href;
                        load_content.style = '';
                    } else {
                        if(String(itme.innerText).indexOf('前一页') <= 0)
                            currentContent.appendChild(itme);
                    }
                }
            }

            load_progress.close();
        },
        error: function (err) {
            alert(err);
        }
    });

}
